package com.stefanini.pe.bbva.bp.in.converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

import com.stefanini.pe.bbva.bp.in.utils.Util;

@FacesConverter(value="porcentajeConverte")
public class PorcentajeConverter implements Converter {

	public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
		return null;
	}

	public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
		Double db = new Double("0");
		try{
			db = new Double(Util.getStringF(arg2).trim());
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return Util.formatDoublePorcentaje(db);
	}
}
